__author__ = 'YinDu'

from .. import app
from utils.PathTool import *
from utils.ProjectTool import *


@app.task
def test11(stock_time=time_wee_hours(), stock_name='sh000006', price=None, time_now=None):
    """
    储存数据
    :param stock_time: 时间  年 月 日
    :param stock_name: 股票 编号
    :param price: 股票价格
    :param time_now: 当时时间
    """
    timestamp = str_change_timestamp(stock_time + ' ' + time_now)
    the_path = to_path('utils/textbool/' + str(stock_name) + '_' + str(stock_time) + '.txt')
    text_path = Path(the_path)
    if text_path.exists():
        text_data = wot.with_open_text_read(the_path, 'r')
        text_data[str(timestamp)] = price
    else:
        text_data = {str(timestamp): price}
    wot.with_open_text_write(the_path, 'w', text_data)
